#ifndef RSIM_FILEIO_H
#define RSIM_FILEIO_H

/* -------------------------------------------------------------------------- *
 * File: FileIO.h							      *
 * Authors: Kishor Bhalerao                                                   *
 * Email : kishor8dm@gmail.com                                                *
 * Contributors:                      					      *
 * Email: 								      *
 * copyright (c) 2010 Authors.                                                *
 *                                                                            *
 * This program is free software: you can redistribute it and/or modify it    *
 * under the terms of the GNU General Public License as published by the Free *
 * Software Foundation, either version 3 of the License, or any later version.*
 *									      *
 * This program is distributed in the hope that it will be useful, but        *
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   *
 * for more details. (http://www.gnu.org/licenses/)			      *
 * -------------------------------------------------------------------------- */

#include <fstream>
using namespace std;
namespace RSIM{
class State;

namespace FileIO{
	
bool checkFileExists(const char FileName[]="rsimout");

void writeArrayToFile(double const* const *ptr, const int num_elements, const int num_array = 1, const char FileName[]="rsimout",  const int precision=16);

void write_append_ArrayToFile(double const* const *ptr, const int num_elements, const int num_array = 1, const char FileName[]="rsimout",  const int precision=16);
		
void write_append_SingleArrayToFile(const double& val, double const *ptr, const int num_elements, const char FileName[]="rsimout",  const int precision=16);

void write_append_SingleArrayToFile(fstream& OpFile, const double& val, double const *ptr, const int num_elements, const char FileName[]="rsimout",  const int precision=16);

/** 
Write State vector [q u]' 
@param Opfile State Vector along with time stamp is writtne to this file
@param precision default value is 16
*/
void appendStateVectorToFile(const State& state,  
			     fstream& OpFile, 
			     const int precision=16);
		
	
} // namespace FileIO
} // namespace RSIM
#endif 